package com.znyj.cloud.device.service;

import com.znyj.cloud.device.dao.ReportDao;
import com.znyj.cloud.device.entity.ReportEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

/**
 * Created by gaoliwei02 on 17/6/1.
 */
@Service
public class ReportService {

    @Autowired
    private ReportDao reportDao;

    public int insertReport(ReportEntity reportEntity) {
        return reportDao.insert(reportEntity);
    }

    public int updateAllReport(ReportEntity reportEntity) {
        return reportDao.updateAll(reportEntity);
    }

    public ReportEntity findByDeviceId(String deviceId) {
        return reportDao.findByDeviceId(deviceId);
    }

    public int getDeviceIdNumber(String deviceId) {
        return reportDao.getDeviceIdNumber(deviceId);
    }

    public int deleteDeviceId(String deviceId) {
        return reportDao.deleteDeviceId(deviceId);
    }

    public int updateCommonInfo(ReportEntity reportEntity) {
        return reportDao.updateCommonInfo(reportEntity);
    }

    public int initOfflineDevice() {
        return reportDao.initOfflineDevice();
    }

    public long getChannalAOrderId(String deviceId) {
        return reportDao.getChannalAOrderId(deviceId);
    }

    public long getChannalBOrderId(String deviceId) {
        return reportDao.getChannalBOrderId(deviceId);
    }

    public int updateAInfo(String deviceId,
                           Timestamp orderCreateTimeA,
                           long orderDurationSecA,
                           String userIdA,
                           long orderIdA) {
        return reportDao.updateAInfo(deviceId, orderCreateTimeA, orderDurationSecA, userIdA, orderIdA);
    }

    public int updateBInfo(String deviceId,
                           Timestamp orderCreateTimeB,
                           long orderDurationSecB,
                           String userIdB,
                           long orderIdB) {
        return reportDao.updateBInfo(deviceId, orderCreateTimeB, orderDurationSecB, userIdB, orderIdB);
    }

    public int updateABInfo(String deviceId,
                            Timestamp orderCreateTimeA,
                            long orderDurationSecA,
                            String userIdA,
                            long orderIdA,
                            Timestamp orderCreateTimeB,
                            long orderDurationSecB,
                            String userIdB,
                            long orderIdB) {
        return reportDao.updateABInfo(deviceId, orderCreateTimeA, orderDurationSecA, userIdA, orderIdA, orderCreateTimeB, orderDurationSecB, userIdB, orderIdB);
    }

    public int updateOnlineStatus(String deviceId, String onlineStatus) {
        return reportDao.updateOnlineStatus(deviceId, onlineStatus);
    }

    public int updateOtaTime(String deviceId, Timestamp otaTime) {
        return reportDao.updateOtaTime(deviceId, otaTime);
    }

    public List<Long> findBindPoiid(String deviceId) {
        return reportDao.findBindPoiid(deviceId);
    }

    public int updatePoiid(long poiid, String deviceId) {
        return reportDao.updatePoiid(poiid, deviceId);
    }
}
